from django_filters import rest_framework as filters

class ProblemFilter(filters.FilterSet):
    difficulty = filters.CharFilter(method='difficulty_filter', help_text='难度')
    def difficulty_filter(self, queryset, name, value):
        map = {
            'Easy': '简单',
            'Medium': '中等',
            'Hard': '困难',
        }
        return queryset.filter(type__name=map.get(value))
